package com.ruoyi.common.config;

import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MinIO配置类
 * 
 * @author ruoyi
 */
@Configuration
public class MinioConfig
{
    @Value("${minio.endpoint:http://59.110.39.34:9000}")
    private String endpoint;

    @Value("${minio.accessKey:minioadmin}")
    private String accessKey;

    @Value("${minio.secretKey:minioadmin}")
    private String secretKey;

    @Bean
    public MinioClient minioClient()
    {
        try
        {
            return new MinioClient(endpoint, accessKey, secretKey);
        }
        catch (InvalidEndpointException | InvalidPortException e)
        {
            throw new RuntimeException("MinIO配置错误", e);
        }
    }
}